package com.annotation.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.Random;
import java.util.UUID;

@Component
public class UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    public void insert(){
        String sql="insert into tb_user(username,age) VALUES(?,?)";

        String userName = UUID.randomUUID().toString().substring(0, 5);
        Random  random=new Random();
        int age = random.nextInt(10);

        jdbcTemplate.update(sql,userName,age);
    }
}
